"ui";
activity.window.addFlags(android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
activity.window.setStatusBarColor(android.graphics.Color.TRANSPARENT);
activity.window.getDecorView().setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE | android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

ui.layout(
    <vertical>
        <linear id="appbar" orientation="vertical" h="90">
            <View h="40" w="*"/>
            <frame h="50">
                <img id="back" src="@drawable/ic_arrow_back_black_48dp" padding="12" tint="#ffffff" w="50" h="50" foreground="?selectableItemBackground"/>
                <text id="app_name" textSize="18sp" textStyle="bold" textColor="#ffffff" w="*" text="抢购助手" h="50" gravity="center"/>
            </frame>
        </linear>
        <frame h="*">
        <ScrollView>
            <vertical w="*" h="*">
                <text textSize="20" textStyle="bold" textColor="black" text="淘宝：" w="*" gravity="center_vertical" margin="15 25 15 15"/>
                <horizontal margin="10 0 10 0" h="40">
                    {/* <text id="tqgModel" bg="#FFF43F3B" textColor="#ffffff" text="页面模式" gravity="center" w="0" h="*" layout_weight="1" marginRight="5"/>
                    <text id="tbModel" bg="#FFF43F3B" textColor="#ffffff" text="收藏模式" gravity="center" w="0" h="*" layout_weight="1" marginRight="5" marginLeft="5"/> */}
                    <text id="tbCartModel" bg="#FFF43F3B" textColor="#ffffff" clickable="true" text="购物车" gravity="center" w="0" h="*" layout_weight="1" marginRight="5" foreground="?selectableItemBackground"/>
                    <text id="tbFastUrlModel" bg="#FFF43F3B" textColor="#ffffff" text="BP模式" gravity="center" w="0" h="*" layout_weight="1" marginLeft="5" marginRight="5" foreground="?selectableItemBackground"/>
                    <text id="tbTestModel" bg="#FFF43F3B" textColor="#ffffff" text="测试解密" gravity="center" w="0" h="*" layout_weight="1" marginLeft="5" foreground="?selectableItemBackground"/>
                </horizontal>
                {/* <horizontal margin="10 10 10 0" h="40">
                    <text id="tbCartModel" bg="#FFF43F3B" textColor="#ffffff" clickable="true" text="购物车" gravity="center" w="0" h="*" layout_weight="1" marginRight="5"/>
                    <text id="tbLiveModel" bg="#FFF43F3B" textColor="#ffffff" text="直播" gravity="center" w="0" h="*" layout_weight="1" marginRight="5" marginLeft="5"/>
                    <text id="tbLiveReplyModel" bg="#FFF43F3B" textColor="#ffffff" text="刷屏" gravity="center" w="0" h="*" layout_weight="1" marginLeft="5"/>
                </horizontal> */}

                <text textSize="20" textStyle="bold" textColor="black" text="京东：" w="*" gravity="center_vertical" margin="15 25 15 15"/>
                {/* <horizontal margin="10 0 10 0" h="40">
                    <text id="jdyh" text="京东热销" bg="#FFF43F3B" textColor="#ffffff" gravity="center" w="0" h="*" layout_weight="1" marginRight="5"/>
                    <text id="jdCart" text="购物车" bg="#FFF43F3B" textColor="#ffffff" gravity="center" w="0" h="*" layout_weight="1" marginLeft="5"/>
                    <text id="jdModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center" text="页面模式" w="0" h="*" layout_weight="1"  marginRight="5"/>
                    <text id="jdms" text="整点秒杀" bg="#FFF43F3B" textColor="#ffffff" gravity="center" w="0" h="*" layout_weight="1" marginLeft="5" />
                </horizontal > */}
                <horizontal margin="10 10 10 0" h="40">
                    <text id="jdModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center" text="页面模式" w="0" h="*" layout_weight="1"  marginRight="5" foreground="?selectableItemBackground"/>
                    <text id="jdOrder" bg="#FFF43F3B" textColor="#ffffff" gravity="center" text="订单秒提" w="0" h="*" layout_weight="1" marginLeft="5" foreground="?selectableItemBackground"/>
                </horizontal>
                <horizontal margin="10 10 10 0" h="40">
                    <text id="jdScModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center" text="收藏模式" w="0" h="*" layout_weight="1" marginRight="5" foreground="?selectableItemBackground"/>
                    <text id="jdListenModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center" text="捡漏模式" w="0" h="*" layout_weight="1" marginLeft="5" foreground="?selectableItemBackground"/>
                </horizontal>

                {/* <text textSize="20" textStyle="bold" textColor="black" text="拼多多：" w="*" gravity="center_vertical" margin="15 25 15 15"/>
                <horizontal margin="10 0 10 0" h="40">
                    <text id="pddyh" text="拼多多红包" bg="#FFF43F3B" textColor="#ffffff" gravity="center" w="0" h="*" layout_weight="1" marginRight="5"/>
                    <text id="pddModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center" text="页面模式" w="0" h="*" layout_weight="1" marginLeft="5"/>
                </horizontal> */}

                <text textSize="20" textStyle="bold" textColor="black" text="苏宁：" w="*" gravity="center_vertical" margin="15 25 15 15"/>
                <horizontal margin="10 0 10 0" h="40">
                    <text id="snModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center" text="页面模式" w="0" h="*" layout_weight="1" marginRight="5" foreground="?selectableItemBackground"/>
                    <text id="snCartModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center" text="购物车" w="0" h="*" layout_weight="1" marginLeft="5" foreground="?selectableItemBackground"/>
                </horizontal>

                <text textSize="20" textStyle="bold" textColor="black" text="抖音：" w="*" gravity="center_vertical" margin="15 25 15 15"/>
                <horizontal margin="10 0 10 0" h="40">
                    <text id="dyModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center"  text="直播" w="0" h="*" layout_weight="1" marginRight="5" foreground="?selectableItemBackground"/>
                    <text id="dyReplyModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center"  text="刷屏" w="0" h="*" layout_weight="1" marginLeft="5" foreground="?selectableItemBackground"/>
                </horizontal>
            
                {/* <text textSize="20" textStyle="bold" textColor="black" text="其他平台：" w="*" gravity="center_vertical" margin="15 25 15 15"/>
                <horizontal margin="10 0 10 0" h="40">
                    <text id="hwModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center"  text="华为" w="0" h="*" layout_weight="1" marginRight="5"/>
                    <text id="miModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center"  text="小米" w="0" h="*" layout_weight="1" marginLeft="5"/>
                </horizontal >
                <horizontal margin="10 10 10 20" h="40">
                    <text id="klModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center"  text="考拉" w="0" h="*" layout_weight="1" marginRight="5"/>
                    <text id="crvModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center"  text="华润" w="0" h="*" layout_weight="1" marginRight="5" marginLeft="5"/>
                    <text id="vmModel" bg="#FFF43F3B" textColor="#ffffff" gravity="center"  text="多点" w="0" h="*" layout_weight="1" marginLeft="5"/>
                </horizontal > */}
            </vertical>
        </ScrollView>
        </frame>
    </vertical>
);

ui.appbar.backgroundDrawable = GradientDrawable("LEFT_RIGHT", ["#FFF43F3B", "#FFEC008C"]);

ui.back.on("click",function(){
    ui.finish();
});
/**
 * 转换成系统支持的颜色
 * @param {颜色} color 
 */
function Color(color) {
    return android.graphics.Color.parseColor(color);
}

/**
 * 配置渐变色
 * @param {方向} orientation 
 * @param {颜色数组} color 
 */
function GradientDrawable(orientation, color) {
    var colors = [];
    color.forEach(color => colors.push(Color(color)));
    return new android.graphics.drawable.GradientDrawable(android.graphics.drawable.GradientDrawable.Orientation[orientation], colors);
}

ui.tbCartModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/tb_cart_t.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        // var temp = aes.decrypt(video,"qG5c9BViEC%7K5y");
        // console.log(temp);
        engines.execScript("test", video);
    });
});

ui.tbTestModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/tb_cart_t.txt";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        // var temp = aes.decrypt(video,"qG5c9BViEC%7K5y");
        // console.log(temp);
        engines.execScript("test", video);
    });
});

ui.tbFastUrlModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/tb_bp.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});


ui.jdModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/jd_detail.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});

// ui.jdms.on("click",function(){
//     threads.start(function(){
//         var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/jd_ms.js";
//         var res_script = http.get(Url, {
//             headers: {
//                 'Accept-Language': 'en-us,en;q=0.5',
//                 'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
//             }
//         });
//         var video = res_script.body.string();
//         engines.execScript("test", video);
//     });
// });
//订单秒提交
ui.jdOrder.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/jd_order.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});
ui.jdScModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/jd_sc.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});

ui.jdListenModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/jd_listen.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});

ui.snModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/sn_detail.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});

ui.snCartModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/sn_cart.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});

ui.dyModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/dy_live_qg.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});


ui.dyReplyModel.on("click",function(){
    threads.start(function(){
        var Url = "https://gitee.com/wupk/auto.test/raw/master/test/wine/dy_live_reply.js";
        var res_script = http.get(Url, {
            headers: {
                'Accept-Language': 'en-us,en;q=0.5',
                'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
            }
        });
        var video = res_script.body.string();
        engines.execScript("test", video);
    });
});